Skip to content

Undoing 'export default' change in index.d.ts which broke typescript #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 2, 2018
Merged

Conversation

azizj1
Copy link
Contributor

@azizj1 azizj1 commented Nov 30, 2017

No description provided.

@smrq
Copy link

smrq commented Nov 30, 2017

Related: #177

@smrq
Copy link

smrq commented Nov 30, 2017

I think that entire commit should be reverted instead. This package is an ES module so it should not declare a namespace.

@AntJanus
Copy link
Collaborator

@smrq would this commit actually fix this? I wouldn't mind just merging it in rather than having to go through a commit reversal.

@smrq
Copy link

smrq commented Nov 30, 2017

After doing some more investigation, I think the situation is as follows.

The state of the typings prior to the referenced commit was valid for es/ng-redux.js (ESNext), but invalid for lib/ng-redux.js (CJS) and dist/ng-redux.js (UMD).

The state after the referenced commit is valid for CJS and UMD but invalid for ESNext. Thus, that commit breaks Webpack builds (which use the ESNext version).

After this patch, I think it is valid for UMD and ESNext, but invalid for CJS.

There's some additional complication in that the current state is extra-permissive: it allows you to compile TypeScript code using e.g. the UMD syntax in an environment where you are not using the UMD version of the code, which will result in runtime rather than compile-time errors.

A single typings file can never be valid for both the CJS and ESNext builds, as far as I can tell. The two module exports are mutually exclusive. The UMD build can be supported by adding the namespace and exporting that, but that erroneously makes the UMD syntax compile when using the other builds.

I'm not actually sure what the best course of action is. I'm trying to find an example of another project with multiple mutually-incompatible TypeScript typings.

@AntJanus
Copy link
Collaborator

AntJanus commented Dec 4, 2017

@smrq looking at Redux's own declaration, it doesn't use the namespace idea. It actually just exports interfaces to all the individual methods that you can get from redux. Maybe we can just lose the namespace?

@smrq
Copy link

smrq commented Dec 8, 2017

You're right. Well, if it's good enough for Redux, it should be good enough here.

That said, the export should still be an ES6 default export here, since that's how the code is written. (Redux itself doesn't have a default ES6 export.)

@AntJanus AntJanus merged commit f07cdc0 into angular-redux:master Feb 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants